<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://www.ufida.com/lfw" prefix="lfw" %>
<%@ taglib uri="http://www.ufida.com/uif" prefix="uif" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>

<html>
	<head>
		<lfw:base/>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta http-equiv="Cache-Control" content="no-cache"/>
		<meta http-equiv="Expires" content="0"/>
		<uif:import globalPath="/lfw/frame"/>
		<script type='text/javascript' src='/lfw/frame/script/reference/reference.js'></script>
		<script type='text/javascript' src='/lfw/frame/script/reference/reftree.js'></script>
		<link rel='STYLESHEET' type='text/css' href="/lfw/frame/themes/ncclassic/styles/reference/button.css">
	</head> 
	<body bottommargin="0" topmargin="0" leftmargin="0" rightmargin="0" scroll=no onload="pageBodyScript()" style="background:#D8DFEC">
		<lfw:pageModel className="nc.lfw.reference.model.TreeReferencePageModel">
			<div style="border:solid #98A5C7 1px;height:95%;width:100%;background:#ffffff;margin-top:10px;margin-right:5px;margin-left:5px;margin-bottom:10px">
				<lfw:layout type="border">
					<lfw:layoutPanel position="top" height="50">
						<lfw:layout type="flowv">
							<lfw:layoutPanel>
								<%@include file="header.jsp" %>
							</lfw:layoutPanel>
							<lfw:layoutPanel>
								<%@include file="treeheader.jsp" %>
							</lfw:layoutPanel>
						</lfw:layout>
					</lfw:layoutPanel>
					
					<lfw:layoutPanel position="center">
						<lfw:tree id="reftree" />
					</lfw:layoutPanel>
					
					<lfw:layoutPanel position="bottom" height="30">
						<lfw:layout type="flowh">
							<lfw:layoutPanel width="100%">
							</lfw:layoutPanel>
							<lfw:layoutPanel>
								<lfw:button id="okbt"/>
							</lfw:layoutPanel>
							<lfw:layoutPanel>
							&nbsp;&nbsp;&nbsp;&nbsp;
							</lfw:layoutPanel>
							<lfw:layoutPanel>
								<lfw:button id="cancelbt"/>
							</lfw:layoutPanel>
							<lfw:layoutPanel>
							&nbsp;&nbsp;&nbsp;&nbsp;
							</lfw:layoutPanel>
						</lfw:layout>
					</lfw:layoutPanel>
				</lfw:layout>
			</div>	
		</lfw:pageModel>
		<script>
			function selfBeforeReferenceOk() {
				var selLeafOnly = (getParameter("selLeafOnly") != null && getParameter("selLeafOnly") == "true");
				if(selLeafOnly){
					var tree = getComponent("reftree");
					var node = tree.getSelectedNode();
					if(node == null)
						return true;
					return node.isLeaf;
				}
				return true;
			}
			TreeViewComp.prototype.onAfterSelNodeChange = function(node)
			{	
				var selLeafOnly = (getParameter("selLeafOnly") != null && getParameter("selLeafOnly") == "true");
				if(selLeafOnly){
					if(!node.isLeaf)
						getComponent('okbt').setActive(false);
					else
						getComponent('okbt').setActive(true);
				}
			};

		</script>
	</body>
</html>